package com.cmcc.passenger.data.service

import com.cmcc.passenger.data.entity.AddressBook
import com.cmcc.passenger.data.entity.FavoriteAddress
import com.cmcc.passenger.data.entity.OrderDetail
import com.cmcc.passenger.data.entity.request.*
import com.cmcc.passenger.data.entity.response.*
import com.cmcc.shared.model.AppResponse
import com.cmcc.shared.model.DriverCache
import com.cmcc.shared.model.MsgBean
import io.reactivex.Flowable
import kotlinx.coroutines.Deferred
import okhttp3.MultipartBody
import retrofit2.Response
import retrofit2.http.*

interface AppApiService {

    /**
     * 获取乘客信息
     */
    @GET("consumer/passenger")
    fun getPassengerInfo(): Deferred<Response<AppResponse<PassengerInfo>>>

    /**
     * 创建订单
     * @param order 创建订单所需要的具体信息
     */
    @POST("consumer/order")
    fun createOrder(@Body order: OrderRecord?): Deferred<Response<AppResponse<CreateOrderResponse>>>

    /**
     * 请求订单记录
     * @param page 当前页
     * @param pageSize 每次请求的条数
     * @param role 当前角色1表示乘客，2表示司机
     * @param status 订单状态
     */
    @GET("consumer/order/list")
    fun getOrderRecords(
        @Query("current") page: Int,
        @Query("size") pageSize: Int,
        @Query("role") role: Int,
        @Query("status") status: Int?
    ): Deferred<Response<AppResponse<OrderRecordResponse>>>

    /**
     * 获取隧道列表
     */
    @GET("consumer/tunnel")
    fun getTunnel(): Deferred<Response<AppResponse<List<Tunnel>>>>

    /**
     * 获取小费列表
     */
    @GET("consumer/gratuity-item")
    fun getGratuity(): Deferred<Response<AppResponse<List<Gratuity>>>>

    /**
     * 获取车辆类型列表
     */
    @GET("consumer/dictionary/vehicle/type/list")
    fun getCarCategory(): Deferred<Response<AppResponse<List<CarCategory>>>>

    /**
     * 取消订单
     * @param id 订单id
     */
    @DELETE("consumer/order/cancel/call")
    fun cancelCall(@Query("id") id: String): Deferred<Response<AppResponse<String>>>

    /**
     * 查询正在进行的订单
     */
    @GET("consumer/order/in/process")
    fun queryOrderInProgress(@Query("role") role: Int): Deferred<Response<AppResponse<OrderRecord>>>

    /**
     * 获取更多出行要求的列表
     * @return 返回一个非阻塞可取消的，它包含了返回的结果
     */
    @GET("consumer/order/travel/item/list")
    fun getTravelItemList(): Deferred<Response<AppResponse<TravelItem>>>

    @GET("consumer/dictionary/vehicle/type/list")
    fun getVehicles(): Deferred<Response<AppResponse<List<CarCategory>>>>

    @GET("consumer/dictionary/tunnel/list")
    fun getTunnels(): Deferred<Response<AppResponse<List<Tunnel>>>>

    @GET("consumer/remark")
    fun getRemarks(): Deferred<Response<AppResponse<List<Remark>>>>

    /**
     * 获取附近的司机
     * @param latitude 当前位置的纬度
     * @param longitude 当前位置的经度
     * @param kilometers 以自己为圆心的范围
     */
    @GET("consumer/driver/nearby/list")
    fun nearbyDriver(
        @Query("latitude") latitude: Double,
        @Query("longitude") longitude: Double,
        @Query("kilometers") kilometers: Int
    ): Deferred<Response<AppResponse<List<NearbyCar>>>>

    /**
     * 获取用户常用地址
     * @param passageId passenger's id who you want to delete
     */
    @GET("consumer/common-address")
    fun getAddress(): Deferred<Response<AppResponse<AddressBook>>>

    /**
     * 添加用户常用地址
     */
    @POST("consumer/common-address")
    fun addAddress(@Body address: FavoriteAddress): Deferred<Response<AppResponse<String>>>

    /**
     * Delete an address by address's id
     * @param id address's id
     */
    @DELETE("consumer/common-address")
    fun deleteAddress(@Query("id") id: String): Deferred<Response<AppResponse<String>>>

    /**
     * 修改常用地址
     * @param address
     */
    @PUT("consumer/common-address")
    fun updateAddress(@Body address: FavoriteAddress): Deferred<Response<AppResponse<String>>>


    /**
     * 获取司机缓存，缓存中包含了一些司机的信息
     * @param id driver id
     *
     */
    @GET("consumer/driver/cache")
    fun getDriverCache(@Query("id") id: String): Deferred<Response<AppResponse<DriverCache>>>

    /**
     * 获取订单模板
     * @param id order template id
     */
    @GET("consumer/order/temp")
    fun getOrderTemplate(@Query("id") id: String): Deferred<Response<AppResponse<OrderTemplate>>>

    /**
     * 获取订单详情
     * @param id order id
     */
    @GET("consumer/order/detail")
    fun getOrderDetail(@Query("orderId") id: String): Deferred<Response<AppResponse<OrderDetail>>>

    /**
     * 更新打赏小费
     */
    @POST("consumer/order/fee/bounty")
//    fun updateBounty(@Body updateBounty: UpdateBounty): Deferred<Response<AppResponse<String>>>
    fun updateBounty(@Query("orderId") orderId: String, @Query("amount") remark: String): Deferred<Response<AppResponse<Boolean>>>

    /**
     * 乘客确认司机已经到达
     */
    @POST("consumer/order/arrive/passenger/confirm/{id}")
    fun arrivePassengerConfirm(@Path("id") id: String): Deferred<Response<AppResponse<String>>>

    /**
     * CALL台放弃叫车
     */
    @POST("consumer/order/cancel/order")
    fun cancelOrder(@Query("id") id: String, @Query("remake") remark: String): Deferred<Response<AppResponse<String>>>


    /**
     * 放弃叫车
     */
    @POST("consumer/order/cancel/call")
    fun cancelCall(@Query("id") id: String, @Query("remake") remark: String): Deferred<Response<AppResponse<String>>>

    /**
     * 计算费用
     */
    @POST("consumer/order/computation/fee")
    fun computationFee(@Body requestFee: RequestFee): Deferred<Response<AppResponse<OrderFee>>>


    /**
     * 消息列表
     */
    @GET("/consumer/system/message/list")
    fun list(@Query("pageNum") pageNum: Int,@Query("pageSize") pageSize: Int): Deferred<Response<AppResponse<MsgBean>>>






    /**
     * 查询当前司机信息
     */
    @GET("/consumer/driver/current/info")
    fun info(): Deferred<Response<AppResponse<DiverInfo>>>


    /**
     * 一键上传文件
     *
     * @param multipartBody
     * @return
     */
    @POST("/consumer/file/upload")
    fun upload(@Body multipartBody: MultipartBody?): Deferred<Response<AppResponse<String>>>


    /**
     * 评价接口
     */
    @POST("/consumer/order/evaluate/scoring")
    fun evaluate(@Body request: EvaluateRequest): Deferred<Response<AppResponse<String>>>


    /**
     * 注册
     */
    @POST("/consumer/driver/register")
    fun register(@Body request: RegistRequest): Deferred<Response<AppResponse<String>>>


    /**
     * 獲取驗證碼
     */
    @POST("/consumer/sms/verification/code")
    fun code(@retrofit2.http.QueryMap map: Map<String, String>): Deferred<Response<AppResponse<String>>>




}